package com.lmxdawn.api.common.api;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;

/**
 * API 错误枚举
 * <p>
 *
 * @author jy
 * @since 2023-11-24 13:46
 */
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum ApiErrorCode implements IErrorCode {

	SUCCESS(                        0,  "操作成功"),
	FAILED(                         1,  "操作失败"),

	APP_SUCCESS(                    1,  "操作成功"),
	APP_FAILED(                     0,  "操作失败"),
    COMMON_SUCCESS(                 200, "请求成功"),

	UNAUTHORIZED(                   401, "请求未授权"),

	UNREALNAME(                   402, "请求未授权"),
	REALNAME_FAIL(                   398, "认证失败"),

	UNREAD(                   399, "未读防诈骗提示"),
	FORBIDDEN(                      403, "请求被拒绝"),
	NOT_FOUND(                      404, "未找到请求资源"),
	METHOD_NOT_SUPPORTED(           405, "不支持当前请求方法"),
	MEDIA_TYPE_NOT_SUPPORTED(       415, "不支持当前媒体类型"),
	PARAM_ERROR(                    400, "请求参数错误或缺失"),
	INTERNAL_SERVER_ERROR(          500, "服务器异常"),
    SQL_ERROR(                      510, "数据处理异常"),
    PROGRAM_EXCEPTION_ERROR(        511, "程序异常"),

	PARAM_INVALID(                  600, "{0}参数非法"),
	SAVE_ERROR(                     610, "保存失败"),
	DELETE_ERROR(                   611, "删除失败"),
	DATA_ERROR(                     620, "数据错误"),
	DATA_NOT_EXIST(                 621, "数据不存在"),
	NOT_PERMISSION(                 10015, "该账号无相关权限，请联系管理员"),
	;

	private final Integer code;
	private final String msg;

    /**
     * 状态码
     */
    @Override
    public Integer getCode() {
        return this.code;
    }
    /**
     * 消息
     */
    @Override
    public String getMsg() {
        return this.msg;
    }
}
